<template>
	<view class="page-content">
		<view class="searchBox">
			<m-search :search_list="search_list" @search="search" placeholder="请输入昵称"></m-search>
		</view>
		<u-list v-if="dataList.length" :customStyle="{
			flex:'1',
			marginBottom: '20rpx',
			paddingTop: '20rpx'
			}" height="0px">
			<account_item :dataItem="item" @clickItem="clickListItem" v-for="(item, index) in dataList" :key="index">
			</account_item>
		</u-list>
		<u-empty mode="list" v-else :customStyle="{flex:'1'}"></u-empty>

		<navigator url="/pages/center/account">
			<view class="btmBox c_ffffff" style="margin-bottom: 60rpx;">
				添加帐号
			</view>
		</navigator>
	</view>
</template>

<script>
	import {
		getSearchData,
		getAccountList
	} from '@/config/api.js'

	export default {
		data() {
			return {
				search_list: [],
				searchForm: {},
				dataList: []
			}
		},
		onLoad() {
			this.getSearchOption();
		},
		onShow() {
			this.loadData();
		},
		methods: {
			clickListItem(item) {
				uni.navigateTo({
					url: "/pages/center/account?id=" + item.id
				})
			},
			search(data) {
				this.searchForm = data;
				this.loadData();
			},
			getSearchOption() {
				getSearchData().then(res => {
					this.search_list = res;
				})
			},
			loadData() {
				var data = {
					search_input: this.searchForm.search_input
				}

				data = uni.$u.deepMerge(data, this.searchForm.choiseData);

				getAccountList(data).then(res => {
					this.dataList = res
				})
			}
		}
	}
</script>

<style scoped>
	.accountList {
		box-sizing: border-box;
		width: 100%;
		padding-left: 5%;
		padding-right: 5%;
	}
</style>
